package pl.com.britenet.myredmine.dao.mdb.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import pl.com.britenet.myredmine.commons.enums.Role;

/**
 * Domain class for table USERS.
 * 
 * @author <a href="mailto:pawel.sprysak@britenet.com.pl">Paweł Sprysak</a>
 * 
 */
@Entity
@Cache(region = "permanent", usage = CacheConcurrencyStrategy.READ_WRITE)
//TODO: Make annotation and LightEntity for GWT
//@GenService
@Table(name = "USERS")
public class Users implements Serializable {  //extends LightEntity

    /**
     * Serial number.
     */
    private static final long serialVersionUID = 53940609608738010L;

    /**
     * Id.
     */
    @Id
    @GeneratedValue(generator = "native")
    @GenericGenerator(name = "native", strategy = "native", parameters = { @Parameter(name = "sequence", value = "SEQ_USERS_ID") })
    @Column(name = "ID", nullable = false)
    private Integer id;
    
    /**
     * Login.
     */
    @Column(name = "LOGIN")
    private String login;
    
    /**
     * Password.
     */
    @Column(name = "PASSWORD")
    private String password;
    
    /**
     * Active.
     */
    @Column(name = "ACTIVE")
    private Integer active;

    /**
     * Name.
     */
    @Column(name = "NAME")
    private String name;

    /**
     * Email.
     */
    @Column(name = "EMAIL")
    private String email;
    
    /**
     * Role.
     */
    @Column(name = "ROLE", nullable = false, length = 16)
    @Enumerated(value = EnumType.STRING)
    private Role role;

    /**
     * Add time.
     */
    @Column(name = "ADD_TIME", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date add_time;

    /**
     * Corporate Role.
     */
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CO_ROLE_ID", nullable = false)
    @ForeignKey(name = "FK_USER_CO_ROLE")
    private CoRole coRole;
    
    /**
     * Setter for property "id".
     * 
     * @param id
     *            Value of property "id".
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * Getter for property "id".
     * 
     * @return Value of property "id".
     */
    public Integer getId() {
        return id;
    }

    /**
     * Setter for property "login".
     * 
     * @param login
     *            Value of property "login".
     */
	public void setLogin(String login) {
		this.login = login;
	}

    /**
     * Getter for property "login".
     * 
     * @return Value of property "login".
     */
	public String getLogin() {
		return login;
	}

    /**
     * Setter for property "password".
     * 
     * @param password
     *            Value of property "password".
     */
	public void setPassword(String password) {
		this.password = password;
	}

    /**
     * Getter for property "password".
     * 
     * @return Value of property "password".
     */
	public String getPassword() {
		return password;
	}

    /**
     * Setter for property "active".
     * 
     * @param active
     *            Value of property "active".
     */
	public void setActive(Integer active) {
		this.active = active;
	}

    /**
     * Getter for property "active".
     * 
     * @return Value of property "active".
     */
	public Integer getActive() {
		return active;
	}

    /**
     * Setter for property "name".
     * 
     * @param name
     *            Value of property "name".
     */
	public void setName(String name) {
		this.name = name;
	}

    /**
     * Getter for property "name".
     * 
     * @return Value of property "name".
     */
	public String getName() {
		return name;
	}

    /**
     * Setter for property "email".
     * 
     * @param email
     *            Value of property "email".
     */
	public void setEmail(String email) {
		this.email = email;
	}

    /**
     * Getter for property "email".
     * 
     * @return Value of property "email".
     */
	public String getEmail() {
		return email;
	}

    /**
     * Setter for property "role".
     * 
     * @param role
     *            Value of property "role".
     */
	public void setRole(Role role) {
		this.role = role;
	}

    /**
     * Getter for property "role".
     * 
     * @return Value of property "role".
     */
	public Role getRole() {
		return role;
	}

    /**
     * Setter for property "add_time".
     * 
     * @param add_time
     *            Value of property "add_time".
     */
	public void setAdd_time(Date add_time) {
		this.add_time = add_time;
	}

    /**
     * Getter for property "add_time".
     * 
     * @return Value of property "add_time".
     */
	public Date getAdd_time() {
		return add_time;
	}

    /**
     * Setter for property "coRole".
     * 
     * @param coRole
     *            Value of property "coRole".
     */
	public void setCoRole(CoRole coRole) {
		this.coRole = coRole;
	}

    /**
     * Getter for property "coRole".
     * 
     * @return Value of property "coRole".
     */
	public CoRole getCoRole() {
		return coRole;
	}
}
